import DList from "@/components/dlist";
export default {
  data() {
    return {
      active: 1,
      vanTab:[{
        title:'分享补贴',
        id:1
      },{
        title:'发放明细',
        id:2
      }],
      loading: false,
      finished: false,
      info:false,
      page: 1,
      dataList:[],
      infoList:{}
    };
  },
  mounted() {
    this.getData();
  },
  methods: {
    changeTabs(val) {
      this.loading = false;
      this.finished = false;
      this.page = 1;
      this.dataList = [];
      this.getData();
    },
    async getData() {
      if (this.loading === true || this.finished === true) {
        return;
      }
      this.loading = true;
      this.info = true;
      let url = this.active == 1 ? 'plugin.share-value.frontend.controllers.rewards.index' : 'plugin.share-value.frontend.controllers.give.index'
      let {data,result,msg} = await $http.post(url,{page:this.page});
      if (result === 0) {
        this.$toast(msg);
        return;
      }
      this.info = false;
      if (data.list.data.length === 0 || data.list.data.length < data.list.per_page || data.list.current_page === data.list.last_page) {
        this.finished = true;
      }
      this.dataList.push(...data.list.data);
      this.infoList = data.info;
      this.fun.setWXTitle(this.infoList.name);
      this.page++;
      this.loading = false;
    },
    onLoad(){
      this.info = true;
      this.getData();
    },
  },
  components: { DList }
};
